package org.example.design.Flyweight.controller;

import org.example.design.Flyweight.bean.Activity;
import org.example.design.Flyweight.bean.Stock;
import org.example.design.Flyweight.factory.ActivityFactory;
import org.example.design.Flyweight.factory.RedisUtils;

/**
 * @Classname ActivityController
 * @Description TODO
 * @Date 2020/11/5 2:51 下午
 * @Created by xiangjd
 */
public class ActivityController {
    private RedisUtils redisUtils = new RedisUtils();

    public Activity queryActivityInfo(long id) {
        Activity activity = ActivityFactory.getActivity(id);
        // 模拟从Redis中获取库存变化信息
        Stock stock = new Stock(1000, redisUtils.getStockUsed());
        activity.setStock(stock);
        return activity;
    }

}
